<template>
  <div id="login" class="login-container">
    <div class="top-box">
      <img class="top-line" src="../../static/login-top-01.png">
      <img class="top" src="../../static/login-top-02.png">
    </div>
    <div class="flex-row content">
      <img class="left" src="../../static/login-left.png">
      <el-form ref="form" :model="form" label-position="top" class="login-form">
        <div class="login-title">登录</div>
        <el-form-item>
          <div slot="label" prop="username">
            <div class="label">
              <i class="el-icon-user"></i>账号：
            </div>
          </div>
          <el-input class="input" v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item>
          <div slot="label">
            <div class="label">
              <i class="el-icon-lock"></i>密码：
            </div>
          </div>
          <el-input class="input" v-model="form.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="button" type="success" @click="submitForm('form')">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="bottom">ICP证: 鲁ICP备2022000997号-1</div>
  </div>
</template>

<script>
  export default {
    name: 'login',
    data() {
      return {
        form: {
          username: '',
          password: ''
        },
      };
    },
    methods: {
      submitForm() {
        this.api.post('/web/user/login',this.form).then((res) => {
          if(!res){
            return
          }
          sessionStorage.setItem('token', res.data.result.token);
          sessionStorage.setItem('username', res.data.result.userInfo.username);
          this.$router.push({
            path: '/home',
          })
          this.$message.success('登录成功');
        });
      }
    }
  }
</script>

<style lang="less" scoped>
  .top-box {
    margin-bottom: 40px;
    display: flex;
    justify-content: center;
    position: relative;

    .top {
      position: absolute;
      width: 34.44rem;
      height: 4.44rem;
    }

    .top-line {
      margin-top: 1.39rem;
      width: 12.44rem;
      height: 1.67rem;
      z-index: 1;
    }
  }

  .content {
    align-items: center;
  }

  .left {
    width: 70.22rem;
    height: 49.33rem;
    object-fit: contain;
  }

  .login-form {
    margin-left: 60px;
    padding: 0 40px;
    min-width: 26.44rem;
    min-height: 35rem;
    background: rgba(33, 42, 57, 0.39);
    border: 1px solid #2F3C51;
    border-radius: 21px;
    box-sizing: border-box;

    .label {
      color: #fff;
      font-size: 18px;

      i {
        margin-right: 10px;
      }
    }

    .input {
      /deep/ .el-input__inner {
        height: 3.33rem;
        background-color: #2F3948;
        border: 0;
        color: #fff;
        font-size: 18px;
      }
    }

    .button {
      margin-top: 1.8rem;
      width: 100%;
      height: 3.48rem;
      font-size: 18px;
    }
  }

  /* 标题 */
  .login-title {
    padding: 50px 0;
    font-weight: 400;
    font-size: 28px;
    color: #fff;
  }

  /* 背景 */
  .login-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    // min-width: 1400px;
    height: 100%;
    background: #1D2532;
    // position: fixed;
    overflow: auto;
  }

  .bottom {
    text-align: center;
    color: #bcbcbc;
  }
</style>
